﻿using How2jVue.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace How2jVue.Controllers.Contexts
{
    public class HeroContext
    {
        List<Hero> _heros;

        public HeroContext()
        {
            _heros = new List<Hero> {
                new Hero { Name="Jack", Health=50 },
                new Hero { Name="Tom", Health=60 }
            };
        }

        internal List<Hero> Get()
        {
            return _heros;
        }

        internal void Add(Hero hero)
        {
            _heros.Add(hero);
        }

        internal void Update(int idx,Hero hero)
        {
            _heros[idx] = hero; 
        }

        internal Hero Get(string name)
        {
            return _heros.FirstOrDefault(h => h.Name == name);
        }

        internal void Delete(string name)
        {
            var hero = Get(name);
            _heros.Remove(hero);
        }
    }
}